/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"4A3B8EE4-8418-440B-85D7-D5E019335BB3",variableType:4}
 */
var fCodProveedor = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"20499F63-B26E-4957-8F32-14D5CBFD54A7",variableType:4}
 */
var fEstado = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"DF8294AE-DF9D-48FE-B49F-0269A35FA409",variableType:4}
 */
var fProveedor = null;

/**
 * @type {Date}
 *
 * @properties={typeid:35,uuid:"23B297A4-7D3F-487C-9EDF-6F06B0D0CE54",variableType:93}
 */
var fFechaHasta = null;

/**
 * @type {Date}
 *
 * @properties={typeid:35,uuid:"62A93460-E6E4-4CBB-856F-38141CBB447D",variableType:93}
 */
var fFechaDesde = null;

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"DF8DD2EA-084D-4D1A-BF42-894555703E70"}
 */
function iraDtl(event) {
	//forms.oc_cabecera_dtl.controller.show()
	forms.oc_cabecera_dtl.controller.loadRecords(oc_cabecera_id)
	globals.mostrarForm('oc_cabecera_dtl')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"98A842B0-D47E-4A40-A948-0DB453CA4772"}
 * @AllowToRunInFind
 */
function busca(event) {
	controller.find()
	
	if (fFechaDesde != null && fFechaHasta != null)
	{
		var rango = utils.dateFormat(fFechaDesde,'dd-MM-yyyy') + '...' + utils.dateFormat(fFechaHasta, 'dd-MM-yyyy')
		fecha = '#' + rango + '|dd-MM-yyyy'
	}
	proveedor_id = fProveedor
	oc_estado = fEstado
	
	if (controller.search() == 0)
		globals.DIALOGS.showWarningDialog('Aviso','No hay resultados','OK')
	else
		controller.sort('fecha desc')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"7C357DE9-0424-4D8C-BCD7-7CFD436A36EE"}
 */
function fechasNulas(event) {
	fFechaDesde = null
	fFechaHasta = null
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"68EE0163-3E3A-4519-B324-C514E5B1B210"}
 */
function proveNulo(event) {
	fProveedor = null
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"4427103C-9872-497F-B970-91E4F8897CE6"}
 */
function onShow(firstShow, event) {
	controller.sort('oc_cabecera_id desc')
	
	fFechaDesde = globals.gFechaDesde
	fFechaHasta = globals.gFechaHasta
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"1343D19D-8B9B-47A0-BAF7-5CC8D006F539"}
 * @AllowToRunInFind
 */
function todos(event) {
	controller.loadAllRecords()
	controller.sort('fecha desc')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"C2720B38-465A-4F27-9F3D-A272E2F4F780"}
 */
function estadoNulo(event) {
	fEstado = null
}
